<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2016/9/21
 * Time: 9:47
 * 产品入库
 */

require('../include/init.inc.php');
$action = $id = $products_id = $model = $name = $color = $size = $price = $currency = $pg = $desc = '';
extract($_REQUEST, EXTR_IF_EXISTS);

$product = array();
if ($action == 'modify') {
    $product = AdminProducts::getProductById($id);
    $getType = explode("_", $product['products_model']);
    array_push($product, $getType[0]);
}

if (Common::isPost() && $action == 'modify_action') {

    $data = array("products_model" => $model, "products_name" => $name, "products_price" => $price, "products_description" => $desc, "products_currency" => $currency, "products_evaluate" => $pg, "products_size" => $size, "products_color" => $color);
    $result = AdminProducts::update($products_id, $data);


    if ($result) {
        SysLog::addLog(UserSession::getUserName(), 'Update', 'ProductsUpdate', $name, json_encode($data));
        Common::exitWithSuccess('修改完成', 'entpot/products.php');
    } else {
        OSAdmin::alert("error");
    }
}

$confirm_html = OSAdmin::renderJsConfirm("icon-remove");
Template::assign('osadmin_action_confirm', $confirm_html);
Template::assign('_GET', $product);
Template::display('entpot/products_modify.tpl');